package com.addplus.townmall.server.api.mapper.town;

import com.addplus.townmall.server.api.model.town.AppNavigationConfig;
import com.addplus.townmall.server.api.model.town.expand.AppNavigationConfigExpand;
import com.addplus.townmall.server.api.utils.BaseAddMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商城导航配置 Mapper 接口
 * </p>
 *
 * @author zhangjiehang
 * @since 2018-08-27
 */
public interface AppNavigationConfigMapper extends BaseAddMapper<AppNavigationConfig> {

    @Select("SELECT\n" +
            " a.id,\n" +
            " a.`name`,\n" +
            " a.icon_path,\n" +
            " a.skip_obj,\n" +
            " r.skip_url,\n" +
            " r.skip_router_type,\n" +
            " r.wildcard_count \n" +
            "FROM\n" +
            " app_navigation_config a\n" +
            " INNER JOIN town_skip_router r ON r.id = a.skip_router_id \n" +
            " AND a.is_delete = 0 \n" +
            "WHERE\n" +
            " a.show_platform = #{showPlatform} \n" +
            " AND a.is_delete = 0 \n" +
            "ORDER BY\n" +
            " a.sort ASC")
    List<AppNavigationConfigExpand> getAppNavigationConfigByPlatform(@Param("showPlatform") Integer showPlatform);

    @Select("SELECT\n" +
            " a.id,\n" +
            " a.`name`,\n" +
            " a.icon_path,\n" +
            " a.skip_obj,\n" +
            " a.skip_router_id,\n" +
            " a.`remark`,\n" +
            " a.`sort`,\n" +
            " a.`gmt_modified`,\n" +
            " r.skip_name,\n" +
            " r.skip_type,\n" +
            " r.skip_router_type,\n" +
            " r.wildcard_count \n" +
            "FROM\n" +
            " app_navigation_config a\n" +
            " INNER JOIN town_skip_router r ON r.id = a.skip_router_id \n" +
            " AND a.is_delete = 0 \n" +
            "WHERE\n" +
            "a.is_delete = 0 \n" +
            "ORDER BY\n" +
            " a.sort ASC")
    List<AppNavigationConfigExpand> getAppNavigationConfigExpandByPage(@Param("page") Page page);

}
